package com.zws.cucumber.optimization.socket.oio;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class ZwsSocketImplAdapterInputStream extends InputStream {

    private ZwsSocketImplAdapter adapter;

    public ZwsSocketImplAdapterInputStream(ZwsSocketImplAdapter adapter) {
        this.adapter = adapter;
    }

    @Override
    public int read() throws IOException {
        return adapter.activeInputStream().read();
    }

    @Override
    public int read(byte[] b) throws IOException {
        return adapter.activeInputStream().read(b);
    }

    @Override
    public int read(byte[] b, int off, int len) throws IOException {
        return adapter.activeInputStream().read(b, off, len);
    }

    @Override
    public byte[] readAllBytes() throws IOException {
        return adapter.activeInputStream().readAllBytes();
    }

    @Override
    public byte[] readNBytes(int len) throws IOException {
        return adapter.activeInputStream().readNBytes(len);
    }

    @Override
    public int readNBytes(byte[] b, int off, int len) throws IOException {
        return adapter.activeInputStream().readNBytes(b, off, len);
    }

    @Override
    public long skip(long n) throws IOException {
        return adapter.activeInputStream().skip(n);
    }

    @Override
    public void skipNBytes(long n) throws IOException {
        adapter.activeInputStream().skipNBytes(n);
    }

    @Override
    public int available() throws IOException {
        return adapter.activeInputStream().available();
    }

    @Override
    public void close() throws IOException {
        adapter.activeInputStream().close();
    }

    @Override
    public synchronized void mark(int readlimit) {
        try {
            adapter.activeInputStream().mark(readlimit);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public synchronized void reset() throws IOException {
        adapter.activeInputStream().reset();
    }

    @Override
    public boolean markSupported() {
        try {
            return adapter.activeInputStream().markSupported();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public long transferTo(OutputStream out) throws IOException {
        return adapter.activeInputStream().transferTo(out);
    }
}
